package com.awesome.spring.limit;

import org.springframework.cloud.gateway.filter.ratelimit.KeyResolver;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * ApiKeyResolver
 *
 * @author alex wu
 * @date 2023/09/17
 */
@Component
public class ApiKeyResolver implements KeyResolver {
    @Override
    public Mono<String> resolve(ServerWebExchange exchange) {
        System.out.println("API限流: " + exchange.getRequest().getPath().value());
        return Mono.just(exchange.getRequest().getPath().value());
    }
}
